import os

import yaml


def load_config(config_file='config.yaml'):
    config_file = os.path.join(os.path.dirname(__file__), config_file)
    """
    读取yaml配置文件
    :param config_file:
    :return:
    """
    try:
        with open(config_file, 'r', encoding='utf-8') as file:
            config = yaml.safe_load(file)
        return config
    except FileNotFoundError:
        print(f"Attempting to load config from: {config_file}")
        print(f"配置文件 {config_file} 未找到，请确保该文件存在于指定路径。")
        raise
    except UnicodeDecodeError:
        print(f"无法解码文件 {config_file}，请检查文件编码。")
        raise